#include<stdio.h>

void compare(int *arr,int start ,int end)
{
    if (start>=end)
    {
        return;
    }
    int left=start;
    int right=end;
    int pivot=arr[left];
    while (left<right)
    {
        while (pivot<=arr[right]&&left<right)
        {
            right--;
        }
        if (left<right)
        {
            arr[left]=arr[right];
            left++;
        }
        while (arr[left]<=pivot&&left<right)
        {
            left++;
        }
        if (left<right)
        {
            arr[right]=arr[left];
            right--;
        }
    }
    if (right==left)
    {
        arr[right]=pivot;
    }
    compare(arr,start,left-1);
    compare(arr,right+1,end);
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int arr[m];
    for (int i=0;i<m;i++)
    {
        scanf("%d",&arr[i]);
    }
    compare (arr,0,m-1);
    for (int i=0;i<m;i++)
    {
        printf("%d ",arr[i]);
    }
}
